package com.example.yan_music.widge.dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;

import com.example.yan_music.R;

/**
 * 自定义的AlertDialog，只有一个“确认”的选项
 */
public class SingleDialog extends AlertDialog {

    private TextView tv_confirm;
    private int mDialogLayoutRes;

    public  SingleDialog(@NonNull Context context) {
        super(context);
    }

    public  SingleDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    public void setLayoutRes(int layoutRes){
        this.mDialogLayoutRes = layoutRes;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(mDialogLayoutRes);
        Window window = getWindow();
        window.setWindowAnimations(R.style.dialog_enter_and_exit_animation_1);
        tv_confirm = findViewById(R.id.tv_confirm);
        tv_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

}
